home *** CD-ROM | disk | FTP | other *** search
- /*
- <!-- ***** BEGIN LICENSE BLOCK *****
- - Version: MPL 1.1/LGPL 2.1
- -
- - The contents of this file are subject to the Mozilla Public License Version
- - 1.1 (the "License"); you may not use this file except in compliance with
- - the License. You may obtain a copy of the License at
- - http://www.mozilla.org/MPL/
- -
- - Software distributed under the License is distributed on an "AS IS" basis,
- - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- - for the specific language governing rights and limitations under the
- - License.
- -
- - The Original Code is PeerAware Workspace User Interface.
- -
- - The Initial Developer of the Original Code is
- - Imunin Software Inc.
- - Portions created by the Initial Developer are Copyright (C) 2006-2008
- - the Initial Developer. All Rights Reserved.
- -
- - Contributor(s):
- -
- - Alternatively, the contents of this file may be used under the terms of
- - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- - in which case the provisions of the LGPL are applicable instead
- - of those above. If you wish to allow use of your version of this file only
- - under the terms of the LGPL, and not to allow others to
- - use your version of this file under the terms of the MPL, indicate your
- - decision by deleting the provisions above and replace them with the notice
- - and other provisions required by the LGPL. If you do not delete
- - the provisions above, a recipient may use your version of this file under
- - the terms of any one of the MPL or the LGPL.
- -
- - ***** END LICENSE BLOCK ***** -->
- */
-
- var LocalHubListBody;
- var LocalHubListCount = 0;
- var FavouriteHubListBody;
- var FavouriteHubListCount = 0;
-
- var xmlHttpRequest;
- var xslt;
- gManageLocalHubs = false;
-
- function show(object){document.all[object].style.visibility='visible';document.all[object].style.display='';}
- function hide(object){document.all[object].style.visibility='hidden';document.all[object].style.display='none';}
-
- //web server
- var iWebServerPort;
- function openWebServer(){window.open("http://localhost:" + iWebServerPort + "/");}
- function SetLocalWebServerPort(aWebServerPort){iWebServerPort = aWebServerPort;}
-
- //hub list
- var iDS;
- function SetPublicHublist(aHublist)
- {
- iDS = aHublist;
- //loadPublicList();
- window.setTimeout('loadPublicList()', 10);
- }
-
- //reg name
- function SetPeerAwareName(aName){document.all("PeerAwareName").innerHTML = aName;}
-
- function loadPublicList()
- {
- try
- {
- xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
- xmlHttpRequest.open("GET", iDS, true);
- xmlHttpRequest.onreadystatechange = function(){publicListLoaded();}
- xmlHttpRequest.send(null);
- }
- catch (E)
- {
- document.all("plist").innerHTML = "Could not load " + url;
- }
- }
-
- function publicListLoaded()
- {
- if (xmlHttpRequest.readyState == 4)
- {
- if(xmlHttpRequest.status == 200)
- {
- var xsl = new ActiveXObject("Microsoft.XMLDOM");
- xsl.async = false;
- xsl.loadXML(xslt);
- document.all("plist").innerHTML = xmlHttpRequest.responseXML.transformNode(xsl);
- }
- else
- {
- document.all("plist").innerHTML = "Could not load " + iDS + "<a href='javascript:window.location.reload();'> retry?</a>";
- }
- }
- }
-
- function toFriendlySize(bs)
- {
- if (bs >= 1024)
- {
- bs = bs / 1024;
- if (bs >= 1024)
- {
- bs = bs / 1024;
- if (bs >= 1024)
- {
- bs = bs / 1024;
- if (bs >= 1024)
- {
- bs = bs / 1024;
- if (bs >= 1024)
- {
- bs = bs / 1024;
- return bs + ' TB';
- }
- else
- return bs + ' TB';
- }
- else
- return bs + ' GB';
- }
- else
- return bs + ' MB';
- }
- else
- return bs + ' KB';
- }
- else
- return bs + ' B';
- }
-
- function AddLocalHub(hubName, hubDescription, hubAddress, maxUsers, minShare, localHub, localHost)
- {
- var p1 = document.all[localHub + hubAddress];
- var editingExisting = false;
- if (p1 != undefined)
- {
- editingExisting = true;
- while (p1.hasChildNodes())
- {
- p1.removeChild(p1.firstChild);
- }
- }
- else
- {
- p1 = document.createElement('p');
- }
- p1.setAttribute("id", localHub + hubAddress);
- var newLink = document.createElement('a');
- newLink.setAttribute('href', hubAddress);
- newLink.setAttribute('id', "address" + localHub + hubAddress);
- var linkText=document.createTextNode(hubName);
- newLink.appendChild(linkText);
- p1.appendChild(newLink);
- t=document.createElement("TABLE");
- tb=document.createElement("TBODY");
- cr=document.createElement("TR");
- cc=document.createElement("TD");
- cc.className="j";
- f1=cc.appendChild(document.createElement("FONT"));
- f1.setAttribute("size","-1");
- var tt = document.createTextNode(hubDescription);
- f1.appendChild(tt);
-
- var connectLink=document.createElement('a');
- connectLink.setAttribute('href',hubAddress);
- connectLink.className="arrow";
- var connectText=document.createTextNode(" " + getTranslation(268));
- connectLink.appendChild(connectText);
- f1.appendChild(connectLink);
-
- f1.appendChild(document.createElement("br"));
- f2=f1.appendChild(document.createElement("FONT"));
- f2.setAttribute("size","-4");
- f2.setAttribute("color","#008000");
- f2.appendChild(document.createTextNode( hubAddress + " - " + getTranslation(53) + " " + maxUsers + " - " + getTranslation(54) + " " + toFriendlySize(minShare) + " - "));
-
- newLink=document.createElement('a');
- if (localHub == "L$")
- {
- newLink.setAttribute('href',"javascript:window.external.AddFav('" + hubName + "','" + hubAddress + "','" + hubDescription + "','" + maxUsers + "','" + minShare + "');");
- var linkText=document.createTextNode(getTranslation(269));
-
- }
- else
- {
- newLink.setAttribute('href',"javascript:window.external.RemFav('" + hubAddress + "');");
- var linkText=document.createTextNode("Delete");
- }
- newLink.className="fl";
- newLink.appendChild(linkText);
- f2.appendChild(newLink);
-
- if (localHub != "L$")
- {
- f2.appendChild(document.createTextNode(" - "));
- newLink = document.createElement('a');
- newLink.setAttribute('href',"javascript:EditFav('" + hubName + "','" + hubAddress + "','" + hubDescription + "','" + maxUsers + "','" + minShare + "','','" + localHub + "');");
- var linkText=document.createTextNode("Edit");
- newLink.className="fl";
- newLink.appendChild(linkText);
- f2.appendChild(newLink);
- }
-
-
- cr.appendChild(cc);
- tb.appendChild(cr);
- t.appendChild(tb);
- p1.appendChild(t);
- if (!editingExisting)
- {
- if (localHub == "L$")
- {
- LocalHubListBody.appendChild(p1);
- LocalHubListCount++;
- show("Local");
- show('LocalList');
- }
- else
- {
- FavouriteHubListBody.appendChild(p1);
- FavouriteHubListCount++;
- show("Favourite");
- show('FavouriteList');
- }
- }
- if (localHost=="Y")
- {
- //navigate to the url:
- if (gManageLocalHubs)
- window.navigate("#address" + localHub + hubAddress);
-
- TestAvailability(hubAddress,hubName,hubDescription);
- /*
- f2.appendChild(document.createTextNode(" - "));
- newLink = document.createElement('a');
- newLink.setAttribute('href',"javascript:TestAvailability('" + hubAddress + "','" + hubName + "','" + hubDescription +"');");
- var linkText=document.createTextNode(getTranslation(267));
- newLink.className="fl";
- newLink.appendChild(linkText);
- f2.appendChild(newLink); */
- }
- }
-
- function AvailabilityHandler(xmlHttpRequest2, aHubAddress, aHubName, aHubDescription)
- {
- if (xmlHttpRequest2.readyState == 4)
- {
- if(xmlHttpRequest2.status == 200)
- {
- if (xmlHttpRequest2.responseText.substr(0,3) == "YES")
- {
- AvailabilityResult(true, aHubAddress, aHubName, aHubDescription, xmlHttpRequest2.responseText.substr(4));
- }
- else
- {
- AvailabilityResult(false, aHubAddress, aHubName, aHubDescription, xmlHttpRequest2.responseText.substr(4));
- }
- }
- }
- }
-
- function TestAvailability(aHubAddress, aHubName, aHubDescription)
- {
- try
- {
- var xmlHttpRequest2 = new ActiveXObject("Microsoft.XMLHTTP");
-
- var port = aHubAddress.substr(aHubAddress.indexOf(":", 5) + 1);
- port = port.substr(0, port.indexOf("/"));
- xmlHttpRequest2.open("GET", "http://www.peeraware.com/testworkspace.php?port="
- + port + "&protocol=" + aHubAddress.substr(0, aHubAddress.indexOf(":")), true);
-
- xmlHttpRequest2.onreadystatechange = function(){AvailabilityHandler(xmlHttpRequest2, aHubAddress, aHubName, aHubDescription);}
- xmlHttpRequest2.send(null);
- }
- catch (E)
- {
- }
- }
-
- function AvailabilityResult(aSuccess, aHubAddress, aHubName, aHubDescription, aResult)
- {
- var p2 = document.all["L$" + aHubAddress];
- if (p2 != undefined)
- {
- var p1 = document.all["availability" + "L$" + aHubAddress];
- if (p1 != undefined)
- {
- while (p1.hasChildNodes())
- {
- p1.removeChild(p1.firstChild);
- }
- }
- else
- {
- p1 = document.createElement('p');
- p1.className="j";
- p1.setAttribute("id", "availability" + "L$" + aHubAddress);
- p2.appendChild(p1);
- }
- var text;
- if (aSuccess)
- {
- f1 = p1.appendChild(document.createElement("IMG"));
- f1.setAttribute("src","ok.gif");
- text = document.createTextNode(getTranslation(232) + " ");
- f1 = p1.appendChild(document.createElement("FONT"));
- f1.setAttribute("size","-1");
- f1.appendChild(text);
- newLink = document.createElement('a');
- newLink.setAttribute('href', aResult);
- var linkText=document.createTextNode(aResult);
- newLink.className="fl";
- newLink.appendChild(linkText);
- f1.appendChild(newLink);
- f1.appendChild(document.createElement("BR"));
- f1.appendChild(document.createElement("BR"));
-
- //invitation start
- var divElement = document.createElement('div');
- divElement.className = "invite";
- linkText = document.createTextNode(getTranslation(290));
- divElement.appendChild(linkText);
- f1.appendChild(divElement);
-
- var table = document.createElement('table');
- var row = table.insertRow(0);
- var cell = row.insertCell(0);
- var fimage = cell.appendChild(document.createElement("IMG"));
- fimage.setAttribute("src","friends.gif");
-
- cell = row.insertCell(1);
- cell.innerHTML = "<P style='font-size=16px;'><a href='mailto:mail@address?subject=" +
- encodeURIComponent(getTranslation(283)) + "&body=" +
- encodeURIComponent(getTranslation(284)) +
- "%3A%0D%0A%0D%0A" + encodeURIComponent(getTranslation(285)) +
- "%2C%0D%0A%0D%0A" + encodeURIComponent(getTranslation(286)) +
- "%0D%0A" + encodeURIComponent(getTranslation(287)) + "%3A%0D%0A%0D%0A" +
- encodeURIComponent("http://www.peeraware.com/invitation.php?url=" + aResult) +
- "%0D%0A%0D%0A'>" + getTranslation(291) + "</a> " + getTranslation(292) + " <a href='" + "http://www.peeraware.com/invitation.php?url=" + aResult + "' target='_blank'>" + getTranslation(293) + "</a>. </P><P style='font-size=16px;'>" + getTranslation(294) + "</P>";
- f1.appendChild(table);
- //invitation end
-
- f1.appendChild(document.createElement("BR"));
- newLink = document.createElement('a');
- newLink.setAttribute('href', "http://www.peeraware.com/workspace/submit.php?url=" + encodeURIComponent(aResult) + "&title=" + encodeURIComponent(aHubName) + "&description=" + encodeURIComponent(aHubDescription));
- newLink.setAttribute('target', "_blank");
- var linkText=document.createTextNode(getTranslation(234));
- newLink.className="fl";
- newLink.appendChild(linkText);
- linkText = document.createTextNode(getTranslation(233) + " ");
- f1.appendChild(linkText);
- f1.appendChild(newLink);
- linkText = document.createTextNode(" " + getTranslation(235));
- f1.appendChild(linkText);
- }
- else
- {
- f1 = p1.appendChild(document.createElement("IMG"));
- f1.setAttribute("src","fail.gif");
- text = document.createTextNode(getTranslation(236));
- f1 = p1.appendChild(document.createElement("FONT"));
- f1.setAttribute("size","-1");
- f1.appendChild(text);
- f1.appendChild(document.createElement("BR"));
- f1.appendChild(document.createElement("BR"));
-
- //invitation start
- var divElement = document.createElement('div');
- divElement.className = "invite";
- linkText = document.createTextNode(getTranslation(290));
- divElement.appendChild(linkText);
- f1.appendChild(divElement);
-
- var table = document.createElement('table');
- var row = table.insertRow(0);
- var cell = row.insertCell(0);
- var fimage = cell.appendChild(document.createElement("IMG"));
- fimage.setAttribute("src","friends.gif");
-
- cell = row.insertCell(1);
- cell.innerHTML = "<P style='font-size=16px;'><a href='mailto:mail@address?subject=" +
- encodeURIComponent(getTranslation(283)) + "&body=" +
- encodeURIComponent(getTranslation(284)) +
- "%3A%0D%0A%0D%0A" + encodeURIComponent(getTranslation(285)) +
- "%2C%0D%0A%0D%0A" + encodeURIComponent(getTranslation(286)) +
- "%0D%0A" + encodeURIComponent(getTranslation(287)) + "%3A%0D%0A%0D%0A" +
- encodeURIComponent("http://www.peeraware.com/invitation.php?url=" + aResult) +
- "%0D%0A%0D%0A'>" + getTranslation(291) + "</a> " + getTranslation(289) + " <a href='" + "http://www.peeraware.com/invitation.php?url=" + aResult + "' target='_blank'>" + getTranslation(293) + "</a>. </P><P style='font-size=16px;'>" + getTranslation(294) + "</P>";
- f1.appendChild(table);
- //invitation end
- }
- }
- }
-
- function RemoveLocalHub(hubAddress,local)
- {
- try
- {
- if (local == "L$")
- {
- LocalHubListBody.removeChild(document.getElementById(local + hubAddress));
- LocalHubListCount--;
- if (LocalHubListCount == 0)
- hide("Local");
- }
- else
- {
- FavouriteHubListBody.removeChild(document.getElementById(local + hubAddress));
- FavouriteHubListCount--;
- if (FavouriteHubListCount == 0)
- hide("Favourite");
- }
- }
- catch (E){}
- }
-
- function Activate(object)
- {
- hide('ShowAbout');
- //hide('Favourite');
- //hide('Local');
- //hide('Public');
- //hide('FavouriteList');
- //hide('LocalList');
- //hide('PublicList');
-
- if (object=='FavouriteList' || object==null)
- {
- if (FavouriteHubListCount)
- {
- show('FavouriteList');
- show('Favourite');
- }
- if (LocalHubListCount)
- {
- show('LocalList');
- show('Local');
- }
- show('PublicList');
- show('Public');
- if (window.external.displayIntro())
- {
- //show("Checkbox2");
- //show("Checkbox");
- //show("ShowIntro");
- }
- }
- else if (object=='ShowIntro')
- {
- //show("Checkbox2");
- //show("Checkbox");
- //show("ShowIntro");
- }
- else if (object=='ShowAbout')
- {
- show('ShowAbout');
- }
- }
-
- function getTranslation(aID)
- {
- if (typeof(window.external)!="undefined" && typeof(window.external.getTranslation)!="undefined")
- return window.external.getTranslation(aID);
- }
-
- function $(aID)
- {
- return document.getElementById(aID)
- }
-
- function setLanguageStrings()
- {
- //$("tws").innerHTML = getTranslation(140);
- //$("tintro").innerHTML = getTranslation(183);
- $("tabout").innerHTML = getTranslation(185);
- $("tlearntouse").title=getTranslation(216);
- $("tlearntouse2").title=getTranslation(216);
- //$("tlearntouse2").innerHTML=getTranslation(183);
- //$("tlearntouse3").title=getTranslation(216);
- $("tuserguide").innerHTML=getTranslation(217);
- //$("tvideotut1").title=getTranslation(219);
- //$("tvideotut2").title=getTranslation(219);
- //$("tvideotut2").innerHTML=getTranslation(220);
- //$("tvideotut3").title=getTranslation(219);
- //$("tvideotut4").innerHTML=getTranslation(219);
- //$("tshowintro").innerHTML=getTranslation(221);
- $("taboutheader").innerHTML=getTranslation(222);
- $("taboutcopyright").innerHTML=getTranslation(223);
- $("tlfav").innerHTML=getTranslation(224);
- $("tnewfav").innerHTML=getTranslation(225);
- $("taddfav").innerHTML=getTranslation(226);
- $("taddfav").title=getTranslation(227);
- $("tlocalnet").innerHTML=getTranslation(218);
- $("tlocalnetdesc").innerHTML=getTranslation(228);
- $("taddws").innerHTML=getTranslation(31);
- $("taddws").title=getTranslation(229);
- $("tinternet").innerHTML=getTranslation(230);
- $("tinternetdes").innerHTML=getTranslation(231);
- }
-
- function startPage()
- {
- setLanguageStrings();
- xslt='<?xml version="1.0" encoding="windows-1252"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">'
- +"<xsl:for-each select='Hublist/Hubs/Hub'><p><a><xsl:attribute name='href'><xsl:value-of select='@Address' /></xsl:attribute><xsl:value-of select='@Name' /></a>"
- +"<table cellpadding='0' cellspacing='0' width='100%'><tbody><tr><td class='j'><font size='-1'>"
- +"<xsl:value-of select='@Description'/><a class='arrow'><xsl:attribute name='href'><xsl:value-of select='@Address' /></xsl:attribute> Connect</a><br/><font size='-4' color='#008000'>"
- +"<nobr><xsl:value-of select='@Address'/> - <xsl:value-of select='@Users'/>/<xsl:value-of select='@Maxusers'/> users - <xsl:value-of select='@Rating'/> - "
- +'<xsl:choose>'
- +'<xsl:when test="@Minshare < 1024"><xsl:value-of select="format-number'
- +"(@Minshare, '#,##0')"
- +'"/>Bytes</xsl:when>'
- +'<xsl:when test="@Minshare < 1048576"><xsl:value-of select="format-number(@Minshare div 1024, '
- +"'#,###.#')"
- +'"/>KB</xsl:when>'
- +'<xsl:when test="@Minshare < 1073741824"><xsl:value-of select="format-number(@Minshare div 1048576, '
- +"'#,###.#')"
- +'"/>MB</xsl:when>'
- +'<xsl:when test="@Minshare"><xsl:value-of select="format-number(@Minshare div 1073741824,'
- +" '#,###.#')"
- +'"/>GB</xsl:when>'
- +'<xsl:otherwise><xsl:text>No </xsl:text></xsl:otherwise>'
- +'</xsl:choose>'
- +" minimun share- <a><xsl:attribute name='href'>javascript:window.external.AddFav('<xsl:value-of select='@Name'/>','<xsl:value-of select='@Address'/>','<xsl:value-of select='@Description'/>','<xsl:value-of select='@Maxusers'/>','<xsl:value-of select='@Minshare'/>');</xsl:attribute> <xsl:attribute name='class'>fl</xsl:attribute>Add to Favorites</a></nobr>"
- +"</font></font></td></tr></tbody></table></p></xsl:for-each></xsl:template></xsl:stylesheet>";
-
- //if (window.external.displayIntro())
- //{
- // document.all("Checkbox").checked = true;
- //}
- //Activate('FavouriteList');
-
- LocalHubListBody = document.getElementById('llist');
- FavouriteHubListBody = document.getElementById('flist');
- window.external.pageLoaded();
- }
-
- function AddInputField(aForm, aInputName, aIdName, aInputValue, aId)
- {
- aForm.appendChild(document.createTextNode(aInputName+": "));
- var edit = document.createElement("input");
- if (aInputValue != "undefined")
- edit.value = aInputValue;
-
- edit.setAttribute("id", aIdName + "edit" + aId);
- aForm.appendChild(edit);
- mybreak=document.createElement("BR");
- aForm.appendChild(mybreak);
- }
-
- function hubEditSave(e)
- {
- var hubName, hubDescription, hubAddress, maxUsers, minShare, localHub;
- localHub = "F$";
- hubName = document.all["Nameedit" + e].value;
- hubAddress = document.all["Addressedit" + e].value;
- hubDescription = document.all["Descriptionedit" + e].value;
-
- if (hubAddress=="")
- alert("Address must have a value.");
- else
- {
- if (hubAddress.search("pa://")==-1)
- hubAddress = "pa://" + hubAddress;
- window.external.UpdateFav(e, hubName, hubAddress, hubDescription);
- if (e!='newfav')
- AddLocalHub(hubName, hubDescription, hubAddress, 0, 0, localHub, '');
- else
- hubEditCancel(e);
- }
- }
-
- function hubEditCancel(e)
- {
- var t = document.all["edit" + e];
- var p = t.parentNode;
- p.removeChild(t);
- if (FavouriteHubListCount == 0)
- {
- hide("Favourite");
- hide('FavouriteList');
- }
- }
-
- function EditFav(aHubName, aHubAddress, aHubDescription, aMaxUsers, aMinShare, aSecure, aLocalHub)
- {
- hide('ShowAbout');
- show("Favourite");
- show('FavouriteList');
-
- if(document.all["edit" + aLocalHub + aHubAddress] == undefined)
- {
- var p1 = document.createElement('p');
- p1.className = "g";
- p1.setAttribute("id", "edit" + aLocalHub + aHubAddress);
-
- var myform = document.createElement("form");
- p1.appendChild(myform);
- mybreak=document.createElement("p");
- myform.appendChild(mybreak);
-
- AddInputField(myform, getTranslation(1), "Name", aHubName, aLocalHub + aHubAddress);
- AddInputField(myform, getTranslation(272), "Description", aHubAddress, aLocalHub + aHubAddress);
- AddInputField(myform, getTranslation(2), "Address", aHubDescription, aLocalHub + aHubAddress);
-
- mybutton=document.createElement("BUTTON");
- mybutton.onclick = function(){hubEditSave(aLocalHub + aHubAddress);};
-
- theText=document.createTextNode(getTranslation(270));
- mybutton.appendChild(theText);
- myform.appendChild(mybutton);
-
- mybutton=document.createElement("BUTTON");
- mybutton.onclick = function(){hubEditCancel(aLocalHub + aHubAddress);};
-
- theText=document.createTextNode(getTranslation(271));
- mybutton.appendChild(theText);
- myform.appendChild(mybutton);
- document.all[aLocalHub + aHubAddress].appendChild(p1);
- }
- }
- function showIntroOnStartup(intro)
- {
- if(intro.checked == true)
- window.external.setDisplayIntro(true);
- else
- window.external.setDisplayIntro(false);
- }
-